package Model;

import java.util.ArrayList;
import java.util.List;

public class User {
    private String username;
    private String email;
    private String password;
    private int age;
    private String address;
    private List<Book> borrowedBooks;

    public User(String username, String email, String password, int age, String address) {
        this.username = username;
        this.email = email;
        this.password = password;
        this.age = age;
        this.address = address;
        this.borrowedBooks = new ArrayList<>();
    }

    // Getter 和 Setter 方法
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public List<Book> getBorrowedBooks() {
        return borrowedBooks;
    }

    public void setBorrowedBooks(List<Book> borrowedBooks) {
        this.borrowedBooks = borrowedBooks;
    }

    // 借书方法
    public void borrowBook(Book book) {
        borrowedBooks.add(book);
        System.out.println("Model.Book borrowed: " + book.getTitle());
    }

    // 还书方法
    public void returnBook(Book book) {
        borrowedBooks.remove(book);
        System.out.println("Model.Book returned: " + book.getTitle());
    }

    // 显示用户信息方法
    public void displayInfo() {
        System.out.println("Username: " + username);
        System.out.println("Email: " + email);
        System.out.println("Age: " + age);
        System.out.println("Address: " + address);
        System.out.println("Borrowed Books:");
        for (Book book : borrowedBooks) {
            System.out.println("- " + book.getTitle());
        }
    }
}